//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.aidong.dao.wills;

import com.aidong.dao.base.ConditionMap;
import com.aidong.dao.base.OrderSet;
import com.aidong.dao.base.Pagination;
import com.aidong.dao.wills.BaseDao;
import com.aidong.model.wills.SmsList;
import java.util.ArrayList;
import java.util.List;
import org.springframework.stereotype.Repository;

@Repository
public class SmsListDao extends BaseDao<SmsList, Integer> {
	public SmsListDao() {
	}

	public void queryPageList(Pagination<SmsList> pg, ConditionMap cd) {
		ArrayList params = new ArrayList();
		String sqlw = cd.toSql(params);
		String sql = "select s.*, m.chName memberName\nfrom SmsList s left join MemberInfo m on s.memberCode=m.memberCode\n" + (sqlw.length() > 0?"where " + sqlw:"") + " order by s.autoId desc";
		this.queryPageListBySql(SmsList.class, pg, sql, params.toArray());
	}

	public List<SmsList> getNotSendList(int num) {
		String sqlww = "status=0 and createTime>convert(datetime, convert(varchar(10),getdate()))";
		return this.queryList(sqlww, (Object[])null, (new OrderSet()).asc("autoId"), num);
	}

	public void updateStatus(SmsList sms) {
		String sql = "update SmsList set status=:p1, sendTime=:p2, sendResult=:p3, taskId=:p4 where autoId=:p5";
		this.updateBySql(sql, new Object[]{sms.getStatus(), sms.getSendTime(), sms.getSendResult(), sms.getTaskId(), sms.getAutoId()});
	}

	public void updateRecvStatus(SmsList sms) {
		String sql = "update SmsList set status=:p1, recvTime=:p2, sendResult=:p3 where taskId=:p4 and mobile=:p5";
		this.updateBySql(sql, new Object[]{sms.getStatus(), sms.getRecvTime(), sms.getSendResult(), sms.getTaskId(), sms.getMobile()});
	}
}
